<div class="header_menu">
    <div class="container">
        <div class="header-nav clearfix">
            <?php echo $this->partial('shop/layout/headerMenu'); ?>
        </div>
    </div>
</div>
</div>

<script src="<?php echo $this->basePath('template/pc/default/js/jqzoom/js/jquery.jqzoom-core.js'); ?>"></script>
<link href="<?php echo $this->basePath('template/pc/default/js/jqzoom/css/jquery.jqzoom.css'); ?>" rel="stylesheet">
<script type="text/javascript">
    $(document).ready(function() {
        $('.jqzoom').jqzoom({
            zoomType: 'standard',
            lens:true,
            preloadImages: true,
            alwaysOn:false,
            zoomWidth: 300,
            zoomHeight: 300
        });
    });
</script>
<style type="text/css">
    ul#thumblist li{float:left;padding-right:2px;list-style:none;}
    ul#thumblist li a{display:block;border:1px solid #CCC;}
    ul#thumblist li a.zoomThumbActive{
        border:1px solid red;
    }
</style>

<div class="container breadcrumbs">
    <?php
    $classMenu = $this->shopHelper()->helperPartial('goodsListHelper', 1, $this->inClassInfo);
    echo $this->partial($classMenu['partialFile'], $classMenu['partialArg']);
    ?>
    <a href="<?php echo $this->url('shop-class', ['action'=>'goodsList', 'id' => $this->inClassInfo->getClassId()]); ?>"><?php echo $this->escapeHtml($this->inClassInfo->getClassName()); ?></a><span class="sep">/</span>
    <span><?php echo $this->escapeHtml($this->goodsInfo[0]->getGoodsName()); ?></span>
</div>

<div class="goods-detail container">
    <div class="goods-detail-info row clearfix">
        <div class="span15">
            <div style="font-size: 23px; font-weight: bold; color: #333;">
                <?php echo $this->escapeHtml($this->goodsInfo[0]->getGoodsName()); ?> <span style="color: #ed145b;"><?php echo $this->escapeHtml($this->goodsInfo[0]->getGoodsExtendName()); ?></span>
            </div>
            <div class="span8 J_mi_goodsPic_block">
                <div id="J_mi_goodsPicBox" class="goods-pic-box">
                <?php
                if(($this->goodsImages && count($this->goodsImages) > 1) || ($this->specImages && count($this->specImages) > 1)) {
                    if($this->specImages) echo $this->partial('shop/goods/goods-spec-image-slide', ['specImages' => $this->specImages, 'goodsInfo' => $this->goodsInfo]);
                    else echo $this->partial('shop/goods/goods-image-slide', ['goodsImages' => $this->goodsImages, 'goodsInfo' => $this->goodsInfo]);
                } else {
                    ?>
                    <div style="margin: 20px 0 10px; width: 430px;height: 410px;">
                        <a rel='gal1' href="<?php echo $this->shopHelper()->baseGoodsImagePath($this->goodsInfo['goodsImage']); ?>" title="<?php echo $this->escapeHtml($this->goodsInfo[0]->getGoodsName()); ?>" class="jqzoom"><img class="goods-big-pic" src="<?php echo $this->shopHelper()->baseGoodsImagePath($this->goodsInfo['goodsThumbnailImage']); ?>"></a>
                    </div>
                <?php } ?>
                </div>
            </div>

            <div class="span7">
                <dl class="goods-info-box">
                    <dt class="goods-info-head" id="spec">
                        <dl>
                            <dd>
                                <strong><?php echo $this->translate('货　号'); ?>：</strong><span id="goods_item"><?php echo $this->specGoodsInfo ? $this->escapeHtml($this->specGoodsInfo->getSpecGoodsItem()) : $this->escapeHtml($this->goodsInfo[0]->getGoodsItem()); ?></span>
                            </dd>
                            <?php
                            $userGroupPriceShowState = $this->shopHelper()->shop('goods_group_price_show', 'goods', 'config');
                            if ($this->goodsInfo['discountPrice'] <= 0) {
                                $userGroupPrice = $this->specGoodsInfo ? unserialize($this->specGoodsInfo->getSpecGoodsUserGroupPrice()) : unserialize($this->goodsInfo[0]->getGoodsUserGroupPrice());
                                if(!empty($userGroupPrice) && $this->shopHelper()->checkUserLoginStatus() && $userGroupPrice[$this->shopHelper()->getUserLoginData('user_group_id')] > 0) {
                                    $shopGoodsPrice = $userGroupPrice[$this->shopHelper()->getUserLoginData('user_group_id')];
                                    echo '<dd><strong>'.$this->translate('价　格').'：</strong><span style="color: #ED145B;font-size: 20px;font-weight:bold;" id="goods_price">'. $this->frontCurrency($shopGoodsPrice) . '</span></dd>';
                                } else {
                                    $shopGoodsPrice = $this->specGoodsInfo ? $this->specGoodsInfo->getSpecGoodsPrice() : $this->goodsInfo[0]->getGoodsPrice();
                                    echo '<dd><strong>'.$this->translate('价　格').'：</strong><span style="color: #ED145B;font-size: 20px;font-weight:bold;" id="goods_price">'. $this->frontCurrency($shopGoodsPrice).'</span></dd>';
                                }
                                if($userGroupPriceShowState == 1 && !empty($userGroupPrice)) {
                                    echo '<dd class="group_price"><strong>'.$this->translate('会员价').'：</strong><span class="group_price" id="group_price_str">';
                                    foreach ($userGroupPrice as $groupPriceKey => $groupPriceValue) {
                                        if($groupPriceValue > 0) echo $this->escapeHtml($this->userGroup[$groupPriceKey]) . '<strong style="color:#ED145B;">'.$this->frontCurrency($groupPriceValue).'</strong>&nbsp;&nbsp;';
                                    }
                                    echo '</span></dd>';
                                }
                            } else {
                                $shopGoodsPrice = $this->goodsInfo['discountPrice'];
                                echo '<dd><strong>'.$this->translate('优惠价').'：</strong><span style="color: #ED145B;font-size: 20px;font-weight:bold;" id="goods_price">'.$this->frontCurrency($shopGoodsPrice).'</span></dd>';
                            } ?>
                            <?php if (!empty($this->goodsInfo['brandName'])) { ?>
                                <dd>
                                    <strong><?php echo $this->translate('品　牌'); ?>：</strong><a href="<?php echo $this->url('shop-brand', ['id' => $this->goodsInfo[0]->getBrandId()]); ?>"><?php echo $this->escapeHtml($this->goodsInfo['brandName']); ?></a>
                                </dd>
                            <?php } ?>
                            <?php
                            if ($this->goodsCustom) {
                                foreach($this->goodsCustom as $customValue) {
                                    ?>
                                    <dd>
                                        <strong><?php echo $this->escapeHtml($customValue->getCustomTitle()); ?>：</strong>
                                        <?php echo $this->escapeHtml($customValue->getCustomContent()); ?>
                                    </dd>
                                <?php } } ?>
                            <dd>
                                <strong><?php echo $this->translate('库　存'); ?>：</strong><span id="goods_stock_show"><?php echo $this->goodsInfo['stockShowState'] == 1 ? $this->shopHelper()->goodsStockShow($this->goodsInfo['stockShow']) : ($this->specGoodsInfo ? ($this->specGoodsInfo->getSpecGoodsStock() <= $this->goodsInfo['stockOutSetNum'] ? $this->shopHelper()->goodsOutStockShow($this->goodsInfo['stockOutShow']) : $this->specGoodsInfo->getSpecGoodsStock()) : ($this->goodsInfo['stockNum'] <= $this->goodsInfo['stockOutSetNum'] ? $this->shopHelper()->goodsOutStockShow($this->goodsInfo['stockOutShow']) : $this->goodsInfo['stockNum'])); ?></span>
                            </dd>
                            <?php
                            $goodsWeight = $this->specGoodsInfo ? $this->specGoodsInfo->getSpecGoodsWeight() : $this->goodsInfo[0]->getGoodsWeight();
                            if($goodsWeight > 0) { ?>
                                <dd>
                                    <strong><?php echo $this->translate('重　量'); ?>：</strong><?php echo $goodsWeight . $this->goodsInfo[0]->getGoodsWeightUnit(); ?>
                                </dd>
                            <?php } ?>
                            <?php if ($this->showData['discountArray'] && !empty($this->showData['discountArray'])) { ?>
                            <dd style="margin-top: 5px;margin-bottom: 5px;">
                                <strong style="float: left;"><?php echo $this->translate('活　动'); ?>：</strong>
                                <div style="margin-left: 60px;">
                                    <?php foreach ($this->showData['discountArray'] as $discountValue) { ?>
                                        <p style="margin-bottom: 3px;"><em class="goods-info-discount"><?php echo $this->escapeHtml($discountValue['tag']); ?></em> <?php echo $this->escapeHtml($discountValue['title']); ?></p>
                                    <?php } ?>
                                </div>
                            </dd>
                            <?php } ?>
                            <?php if ($this->showData['couponArray'] && !empty($this->showData['couponArray'])) { ?>
                                <dd>
                                    <strong><?php echo $this->translate('优惠券'); ?>：</strong>
                                    <?php foreach ($this->showData['couponArray'] as $couponKey => $couponValue) { if ($couponKey == 3) break; ?>
                                        <div style="min-width: 50px;height: 26px;background:#E5004F;line-height:26px;color: #fff;display: inline-block;text-align: center;">
                                            &nbsp;<?php echo $this->translate('满').$this->frontCurrency($couponValue['shoppingAmount']).$this->translate('减').$this->frontCurrency($couponValue['shoppingDiscount']); ?> &nbsp;&nbsp;
                                        </div>
                                        <div style="width: 10px;height: 10px;border-radius: 50%;background: #fff;display: inline-block;margin-left: -10px;position: relative;">
                                        </div>
                                    <?php } ?>
                                    <span>
                                        <a style="text-decoration: underline;" href="<?php echo $this->url('shop-goods', ['action' => 'clickGoodsCoupon', 'id' => $this->goodsInfo[0]->getGoodsId()]); ?>" target="_blank"><?php echo $this->translate('点击领券'); ?></a>
                                    </span>
                                </dd>
                            <?php } ?>

                            <?php if($this->goodsInfo[0]->getGoodsIntegralBuy() == 1) { ?>
                                <dd style="margin-top:8px;font-size: 14px;"><strong><?php echo $this->translate('可积分兑换'); ?>：<?php echo $this->shopHelper()->getGoodsIntegral($shopGoodsPrice); ?></strong></dd>
                            <?php } ?>

                            <?php if($this->goodsInfo[0]->getWholesaleState() == 1 && $this->goodsWholesaleList) { ?>
                            <div class="clearfix" style="margin-bottom: 10px;margin-top: 10px;">
                                <div>
                                    <strong><?php echo $this->translate('批发售价');?></strong>
                                    <table class="edit_table_css" width="90%">
                                        <tr>
                                            <th><?php echo $this->translate('购买数量');?></th>
                                            <th><?php echo $this->translate('单价');?></th>
                                        </tr>
                                        <?php foreach ($this->goodsWholesaleList as $wholesaleValue) { ?>
                                            <tr>
                                                <td style="text-align: center;"><?php echo $wholesaleValue->getWholesaleStartNum() . ' ~ ' . $wholesaleValue->getWholesaleEndNum(); ?></td>
                                                <td style="text-align: center;"><?php echo $this->frontCurrency($wholesaleValue->getWholesalePrice()); ?></td>
                                            </tr>
                                        <?php } ?>
                                    </table>
                                </div>
                            </div>
                            <?php } ?>
                            <form action="<?php echo $this->url('shop-cart', ['action'=>'add']); ?>" method="post" name="addGoodsCartForm" id="addGoodsCartForm">
                            <?php if ($this->goodsSpec) { ?>
                            <dd class="goods-info-head-colors clearfix">
                                <?php foreach ($this->goodsSpec as $goodsSpecValue) { ?>
                                    <span><?php echo $this->escapeHtml($goodsSpecValue['tagGroupName']); ?>：</span>
                                    <div class="clearfix goods_spec_<?php echo $goodsSpecValue['groupId']; ?> goods_spec_tag_item">
                                        <?php if(isset($goodsSpecValue['tagList']) && !empty($goodsSpecValue['tagList'])) { foreach ($goodsSpecValue['tagList'] as $specTagValue) { ?>
                                            <div class="colorli">
                                                <a id="spec_value_<?php echo $specTagValue['tagId']; ?>" <?php if($this->selectedSpecTagId && in_array($specTagValue['tagId'], $this->selectedSpecTagId)) echo 'class="coloractive"'; ?> href="javascript:;" onclick="selectGoodsSpec(<?php echo $specTagValue['tagId']; ?>, <?php echo $goodsSpecValue['groupId']; ?>);" style="cursor: pointer;"><?php echo $this->escapeHtml($specTagValue['tagName']); ?></a>
                                            </div>
                                        <?php } } ?>
                                    </div>
                                <?php } ?>
                                <input type="hidden" name="specTagIdCount" id="specTagIdCount" value="<?php echo count($this->goodsSpec); ?>">
                                <input type="hidden" name="specTagIdStr" id="specTagIdStr" value="<?php if($this->selectedSpecTagId) echo implode(',', $this->selectedSpecTagId); ?>">
                            </dd>
                            <?php } ?>

                            <dd id="goodsDetailBtnBox" class="goods-info-head-cart">
                                <div style="margin-bottom:8px;">
                                    <?php echo $this->translate('我想买'); ?>：
                                    <button class="btn btn-primary" id="add_down" style="cursor: pointer;height: 30px;line-height: 30px;" type="button">-</button>
                                    <input type="text" style="width:30px;margin-bottom:2px;" name="buyNum" id="buyNum" value="<?php echo ($this->goodsInfo['cartBuyMinNum'] > 1 ? $this->goodsInfo['cartBuyMinNum'] : 1); ?>" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
                                    <button class="btn btn-primary" id="add_up" style="cursor: pointer; pointer;height: 30px;line-height: 30px;" type="button">+</button>
                                    <label for="buy_goods_num" generated="true" class="error" style="display: inline-block;"></label>
                                </div>
                                <input type="hidden" id="goodsId" name="goodsId" value="<?php echo $this->goodsInfo[0]->getGoodsId(); ?>" />
                                <button type="button" class="btn btn-primary goods-add-cart-btn" id="add_cart_submit">
                                    <i class="iconfont "></i><?php echo $this->translate('加入购物车'); ?></button>
                                <button type="button" title="<?php echo $this->translate('收藏商品'); ?>" id="button-add-to-wishlist" class="btn <?php echo $this->shopHelper()->getGoodsFavoritesStatus($this->goodsInfo[0]->getGoodsId()) ? 'btn-primary' : 'btn-dake'; ?> goods-collect-btn">
                                    <i class="iconfont"></i>
                                </button>
                                <?php if($this->shopHelper()->shop('goods_qr_code', 'qr_code') == 1) { ?>
                                    &nbsp;<img alt="<?php echo $this->translate('手机扫描后，在手机中访问该商品'); ?>" title="<?php echo $this->translate('手机扫描后，在手机中访问该商品'); ?>" width="60px" src="<?php echo $this->shopHelper()->baseImagePath($this->shopHelper()->helperCreateQrCodeFile($this->url('shop-goods', ['id' => $this->goodsInfo[0]->getGoodsId()], ['force_canonical' => true]), 'goods', $this->goodsInfo[0]->getGoodsId())); ?>">
                                <?php } ?>
                                <button type="button" class="btn btn-primary goods-add-cart-btn" id="buy_now_submit"><?php echo $this->translate('立即购买'); ?></button>
                            </dd>
                            </form>
                            <dd style="margin-top: 3px;">
                                <?php echo $this->translate('最近'); ?><span id="ajax_order_count"><?php echo intval($this->goodsInfo[0]->getVirtualSales() + $this->goodsInfo['goodsSalesNum']); ?></span><?php echo $this->translate('人已经购买'); ?>
                            </dd>
                        </dl>
                    </dt>
                </dl>
            </div>
        </div>

        <div class="span5">
            <div style="border: 1px solid #ed6343;">
                <div style="background-color: #ed6343;padding: 5px;color: #fff;">
                    <strong>&nbsp;<?php echo $this->translate('品质保证'); ?></strong>
                </div>
                <div style="min-height:50px; font-size: 13px; padding: 8px;"><?php echo nl2br($this->escapeHtml($this->shopHelper()->shop('goods_quality', 'content'))); ?></div>
            </div>

            <div style="padding-top: 6px;">
                <div>
                    <?php echo $this->partial($this->goodsPartial[1]['partialFile'], $this->goodsPartial[1]['partialArg']); ?>
                </div>
            </div>
        </div>

    </div>

    <div class="row goods-detail-desc">
        <div class="span5">
            <div class="xm-box goods-alsobuy xm-goods-side-list">
                <div class="box-hd">
                    <div class="title"><?php echo $this->translate('相关商品'); ?></div>
                </div>
                <div class="box-bd">
                    <?php $randGoods = $this->shopHelper()->getShopRandGoods($this->goodsInfo[0]->getGoodsId()); ?>
                    <ul>
                        <?php if ($randGoods) foreach ($randGoods as $rGoodsValue) { ?>
                        <li>
                            <a href="<?php echo $this->url('shop-goods', ['id' => $rGoodsValue[0]->getGoodsId()]); ?>" title="<?php echo $this->escapeHtml($rGoodsValue[0]->getGoodsName()); ?>">
                                <h2><?php echo $this->escapeHtml($rGoodsValue[0]->getGoodsName()); ?></h2>
                                <h2 style="color: #ed6343;font-weight: bold;"><?php echo (isset($rGoodsValue['goodsGroupPrice']) && $rGoodsValue['goodsGroupPrice'] > 0) ? $this->frontCurrency($rGoodsValue['goodsGroupPrice']) : $this->frontCurrency($rGoodsValue[0]->getGoodsPrice()); ?></h2>
                                <div class="star">&nbsp;</div>
                                <img src="" data-original="<?php echo $this->shopHelper()->baseGoodsImagePath($rGoodsValue['goodsThumbnailImage']); ?>" alt="<?php echo $this->escapeHtml($rGoodsValue[0]->getGoodsName()); ?>" class="lazy leftImg">
                            </a>
                        </li>
                        <?php } ?>
                    </ul>
                </div>
            </div>
        </div>

        <div class="span15">
            <div id="goodsDetail" class="xm-box goods-detail-box">
                <div class="box-hd" id="sticky_navigation">
                    <ul class="items clearfix J_pro_related_btns">
                        <li class="current">
                            <a href="#goodsDesc"><?php echo $this->translate('详细信息'); ?></a>
                        </li>
                        <li>
                            <a href="#goodsComment"><?php echo $this->translate('商品评价'); ?></a>
                        </li>
                        <li>
                            <a href="#goodsFaq"><?php echo $this->translate('商品咨询'); ?></a>
                        </li>
                        <li>
                            <a href="#serQue"><?php echo $this->translate('售后服务'); ?></a>
                        </li>
                        <li>
                            <a href="#goodsBuyQue"><?php echo $this->translate('如何购买'); ?></a>
                        </li>
                    </ul>
                </div>
                <?php if($this->goodsCommonContent) foreach ($this->goodsCommonContent as $contentValue) { echo $contentValue->getContentBody(); } ?>
                <?php if(isset($this->goodsAttribute)) { ?>
                    <div id="goodsParam" class="edit_table_css" style="padding-top: 25px;">
                        <div>
                            <table style="width: 100%;">
                                <tbody>
                                <?php
                                $b_num = count($this->goodsAttribute)-1;
                                foreach($this->goodsAttribute as $b_key => $b_val) {
                                    $b_y_num = $b_key%3; if ($b_key == 0) echo '<tr>';
                                    if ($b_y_num==0 and $b_key!=0) echo '</tr><tr>';
                                    if ($b_num==$b_key) {
                                        ?>

                                        <td width="<?php echo 33*(3-$b_y_num); ?>%" colspan="<?php echo (3-$b_y_num); ?>"><?php echo $b_val; ?></td>
                                        </tr>
                                    <?php } else { ?>

                                        <td width="33%"><?php echo $b_val; ?></td>
                                        <?php
                                    }
                                }
                                ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                <?php } ?>
                <div id="goodsDesc" class="box-bd edit_table_css">
                    <?php echo $this->goodsInfo[0]->getGoodsBody(); ?>
                </div>
            </div>
            <div id="goodsComment" class="xm-box goods-detail-comment ">
                <div class="box-hd">
                    <div class="title">
                        <?php echo $this->translate('商品评价'); ?>
                    </div>
                </div>
                <div id="J_goods_detail_comment" class="box-bd">
                    <div class="com-body" id="listGoodsComment"></div>
                </div>
            </div>
            <div id="goodsFaq" class="xm-box goods-detail-faq">
                <div class="box-hd">
                    <div class="title"><?php echo $this->translate('商品咨询'); ?></div>
                </div>
                <div class="box-bd">
                    <div id="listGoodsAsk"></div>
                    <?php
                    $cForm = $this->consultForm;
                    $cForm->prepare();

                    echo $this->form()->openTag($cForm);
                    ?>
                    <div class="faq-input">
                        <?php echo $this->formElement($cForm->get('shopCsrf')); ?>
                        <?php echo $this->formElementErrors($cForm->get('shopCsrf'), ['class'=>'error-message']); ?>

                        <?php echo $this->formElement($cForm->get('consultGoodsId')); ?>
                        <?php echo $this->translate('您的问题'); ?>
                        <?php echo $this->formElement($cForm->get('consultContent')->setAttributes(['class' => 'input-content', 'rows' => 5, 'placeholder' => $this->translate('在这里输入您想咨询的问题')])); ?>
                        <?php echo $this->formElementErrors($cForm->get('consultContent'), ['class'=>'error-message']); ?>
                        <button type="submit" class="btn btn-primary ques-btn J_mi_ask"><?php echo $this->translate('提交咨询'); ?></button>
                        <?php if($this->shopHelper()->shop('goods_ask_captcha', 'captcha') == 1) { ?>
                            <br>
                            <?php echo $this->formElement($cForm->get('consultCaptcha')->setAttributes(['class' => 'form-control', 'placeholder' => $this->translate('输入上面的验证码')])); ?>
                            <?php echo $this->formElementErrors($cForm->get('consultCaptcha'), ['class'=>'error-message']); ?>
                        <?php } ?>
                    </div>
                    <?php echo $this->form()->closeTag(); ?>
                </div>
            </div>
            <div id="serQue" class="common-question">
                <div class="question-hd clearfix">
                    <div class="title_a"><?php echo $this->translate('售后服务'); ?></div>
                </div>
                <div class="question-bd">
                    <?php echo $this->shopHelper()->shop('sales_service', 'content'); ?>
                </div>
            </div>
            <div id="goodsBuyQue" class="common-question" style="margin-top: 30px;">
                <div class="question-hd clearfix">
                    <div class="title_a"><?php echo $this->translate('如何购买'); ?></div>
                </div>
                <div class="question-bd">
                    <?php echo $this->shopHelper()->shop('buy_service', 'content'); ?>
                </div>
            </div>

        </div>
    </div>

</div>

<!-- 跟随 导航 -->
<div class="goods-sub-bar" id="goodsSubBar">
    <div class="container">
        <div class="row">
            <div class="span5">
                <dl class="goods-sub-bar-info clearfix">
                    <dt><img src="<?php echo $this->shopHelper()->baseGoodsImagePath($this->goodsInfo['goodsThumbnailImage']); ?>"></dt>
                    <dd>
                        <strong><?php echo $this->escapeHtml($this->goodsInfo[0]->getGoodsName()); ?></strong>
                        <p>
                            <em><span class="J_mi_goodsPrice"><?php echo $this->frontCurrency($shopGoodsPrice); ?></span></em>
                        </p>
                    </dd>
                </dl>
            </div>
            <div class="span15">
                <div class="fr" id="goodsSubBarBtnBox">
                    <a href="javascript:;"  onclick="goodsAddCart();" class="btn btn-primary goods-add-cart-btn">
                        <i class="iconfont">&#xe624;</i><?php echo $this->translate('加入购物车'); ?>
                    </a>
                </div>
                <div class="goods-desc-menu" id="goodsSubMenu">
                    <ul class="items clearfix J_pro_related_btns">
                        <li class="current">
                            <a href="#goodsDesc"><?php echo $this->translate('详细信息'); ?></a>
                        </li>
                        <li>
                            <a href="#goodsComment"><?php echo $this->translate('商品评价'); ?></a>
                        </li>
                        <li>
                            <a href="#goodsFaq"><?php echo $this->translate('商品咨询'); ?></a>
                        </li>
                        <li>
                            <a href="#serQue"><?php echo $this->translate('售后服务'); ?></a>
                        </li>
                        <li>
                            <a href="#goodsBuyQue"><?php echo $this->translate('如何购买'); ?></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).on('click', '#add_cart_submit', function(event) {
        goodsAddCart();
    });

    function goodsAddCart() {
        $.ajax({
            url: '<?php echo $this->url('shop-cart', ['action'=>'add']); ?>',
            type: 'post',
            dataType: 'json',
            data: $('#addGoodsCartForm').formSerialize(),
            success: function(data) {
                showMessage(data.message);
                if(data.status == 'true') {
                    //if(!data.hasOwnProperty('inSpecGoods')) $('.cart-total').show();
                } else {
                    if(data.hasOwnProperty('loginStatus') && data.loginStatus == 'false') {
                        return window.location.href = '<?php echo $this->url('shop-home'); ?>';
                    }
                }
            }
        });
    }
    $(document).on('click', '#buy_now_submit', function(event) {
        $.ajax({
            url: '<?php echo $this->url('shop-cart', ['action'=>'addBuyNow']); ?>',
            type: 'post',
            dataType: 'json',
            data: $('#addGoodsCartForm').formSerialize(),
            beforeSend: function() {
                $('.button-buy-now').button('loading');
            },
            complete: function() {
                $('.button-buy-now').button('reset');
            },
            success: function(data) {
                if(data.status == 'true') {
                    if(!data.hasOwnProperty('inSpecGoods')) return window.location.href = '<?php echo $this->url('shop-checkout', ['action' => 'buyNow']); ?>';
                    else showMessage(data.message);
                } else {
                    if(data.hasOwnProperty('loginStatus') && data.loginStatus == 'false') {
                        return window.location.href = '<?php echo $this->url('shop-home'); ?>';
                    } else showMessage(data.message);
                }
            }
        });
    });

    $("#add_up").click(function() {
        let buyNum = parseInt($('#buyNum').val());
        let maxNum = <?php echo $this->goodsInfo['cartBuyMaxNum']; ?>;
        if(buyNum >= maxNum && maxNum > 0) {
            showMessage('<?php echo $this->translate('每次购买最多数量为'); ?> '+maxNum);
            return false;
        }
        $('#buyNum').val( parseInt($('#buyNum').val()) + 1 );
    });
    $("#add_down").click(function() {
        let buyNum = parseInt($('#buyNum').val());
        let minNum = <?php echo $this->goodsInfo['cartBuyMinNum']; ?>;
        if(buyNum <= minNum && minNum > 0) {
            showMessage('<?php echo $this->translate('每次购买最少数量为'); ?> '+minNum);
            return false;
        }
        if( parseInt($('#buyNum').val())  > 1 ) {
            $('#buyNum').val( parseInt($('#buyNum').val()) - 1 );
        }
    });

    $('#buyNum').blur(function() {
        if ( $(this).val() < 1 ) $(this).val(1);
    });

    $(document).ready(function() {
        $("#<?php echo $cForm->getName(); ?>").validate({
            rules: {
                consultContent: {
                    required: true
                }
            },
            messages: {
                consultContent: {
                    required: "<?php echo $this->translate('请输入商品咨询内容!'); ?>"
                }
            },
            submitHandler:function(){
                submitConsultForm();
            }
        });
    });
    function submitConsultForm() {
        $.post("<?php echo $this->url('shop-goods', ['action'=>'addGoodsConsult']); ?>",$('#<?php echo $cForm->getName(); ?>').formSerialize(),
            function(data){
                if(data.status == 'true') {
                    $('#consultContent').val('');
                    showMessage('<?php echo $this->translate('您的咨询信息已经成功提交，卖家审核回复后，将正常显示!'); ?>');
                } else {
                    showMessage(data.message);
                }
            }, 'json');
    }

    function selectGoodsSpec(specValueId, groupId) {
        if($('#spec_value_'+specValueId).attr('class') == 'coloractive') {
            $('#spec_value_'+specValueId).attr('class', '');

        } else {
            $('.goods_spec_'+groupId+' a').each(function() {
                $('#'+this.id).attr('class', '');
            });
            $('#spec_value_'+specValueId).attr('class', 'coloractive');
        }

        let specTagCount= $('#specTagIdCount').val();
        let specTagId   = [];
        $.each($('.goods_spec_tag_item a'), function () {
            if($('#'+this.id).attr('class') == 'coloractive') {
                specTagId.push(this.id.replace('spec_value_', ''));
            }
        });

        if(specTagId.length == specTagCount) {
            layer.load(2, {shade: [0.05, '#000'] });
            window.location.href = "?tId="+specTagId.toString()+"#spec";
        }
    }

    //加入对图片的延迟加载
    $('#goodsDesc img').each(function(){
        $(this).addClass('dbshopImgLoading');
        $(this).attr('data-original', $(this).attr('src'));
    });
    $("img.dbshopImgLoading").lazyload({ effect : "fadeIn", skip_invisible : true, failure_limit : 1000 });

    //菜单置顶
    $(function() {
        if($('#sticky_navigation').html() != null) {
            var sticky_navigation_offset_top = $('#sticky_navigation').offset().top;
            var sticky_navigation = function(){
                var scroll_top = $(window).scrollTop();
                if (scroll_top > sticky_navigation_offset_top) {
                    $('#goodsSubBar').addClass('goods-sub-bar-play');
                } else {
                    $('#goodsSubBar').removeClass('goods-sub-bar-play');
                }
            };
            sticky_navigation();
            $(window).scroll(function() {
                sticky_navigation();
            });
        }
    });

    //商品收藏
    $(document).on('click', '#button-add-to-wishlist', function() {
        $.get("<?php echo $this->url('shop-goods', ['action' => 'addGoodsFavorites', 'id' => $this->goodsInfo[0]->getGoodsId()]); ?>", {}, function (data) {
            if(data.status == 'true') {
                if(data.favoritesState == 'add') {
                    $('#button-add-to-wishlist').removeClass('btn-dake');
                    $('#button-add-to-wishlist').addClass('btn-primary');
                }
                if(data.favoritesState == 'remove') {
                    $('#button-add-to-wishlist').addClass('btn-dake');
                    $('#button-add-to-wishlist').removeClass('btn-primary');
                }
            }
            showMessage(data.message);
        }, 'json');
    });

    //商品咨询列表
    dbshopAjaxList('<?php echo $this->url('shop-goods', ['action' => 'goodsConsultList', 'id' => $this->goodsInfo[0]->getGoodsId()]);?>', 'listGoodsAsk');
    //商品评价列表
    dbshopAjaxList('<?php echo $this->url('shop-goods', ['action' => 'goodsEvaluationList', 'id' => $this->goodsInfo[0]->getGoodsId()]);?>', 'listGoodsComment');
</script>

